<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="keywords" content="(www.eblog.site),博文分享，技术博文，影音推荐，美食分享，生活技巧，笑话大全"/>
<meta name="description" content="eBlog分享网(www.eblog.site)为广大朋友们提供有技术的博文，最新最热门的电影音乐。看到就流口水的美食，各种生活技巧，笑喘不过气的笑话！ "/>
<title>详情</title>
<link rel="shortcut icon" href="assets/manager/favicon.ico" /> 
<link href="assets/css/common.css" type="text/css" rel="stylesheet" />
<link href="assets/css/style.css" type="text/css" rel="stylesheet" />
</head>

<body>
<!-- common -->
<%@ include file="header.jsp"%>
<!-- common -->
<!-- wrap -->
<div class="wrap">
    <!-- content -->
    <div class="content">
        <!-- left -->
        <section id="ileft" class="lfloat cleft">
            <article class="article">
                <header class="contHeader">
                    <h2 id="title"></h2>
                    <div class="article_tag">
                        <span class="type" id="type"></span>
                        <span class="tag">标签：<a href="#" id="tag"></a></span>
                        <span class="postDate" id="postD"></span>
                        <p class="article_tagR">
                            <i class="read"></i><span class="readN" id="readN"></span>
                            <i class="tuijian"></i><span class="tuijianN" id="tuijianN"></span>
                        </p>
                    </div>
                </header>
                <div id="intro"></div> 
                <div class="article_cont" id="content">
                </div>
                <footer class="article_footer"><span id="tuijian">推荐</span></footer>
            </article>
            <div class="gotoTop">返回<br>顶部</div>
        </section>
        <!-- left -->
        <!-- right -->
        <section id="iright" class="rfloat">
            <div class="Ritem">
                <dl class="authorInfo">
                    <dt><a href="#"><img src="assets/images/logo.png" id="userPic" alt="用户头像"></a></dt>
                    <dd>
                        <h4><a href="#" id="author"></a></h4>
                        <p><span>原创<em id="ycTotal"></em></span><span>文章<em id="total"></em></span></p>
                    </dd>
                </dl>
            </div>
            <div class="Ritem">
                <h3>阅读排行榜</h3>
                <ul class="RitemUl" id="readTop">
                </ul>
            </div>
            <div class="Ritem">
                <h3>推荐排行榜</h3>
                <ul class="RitemUl" id="tuijianTop">
                </ul>
            </div>
        </section>
        <!-- right -->
    </div>
    <!-- content -->
    <!-- copyright -->
    <%@ include file="footer.jsp"%>
    <!-- copyright -->
</div>
<!-- wrap -->
<script type="text/javascript" src="assets/scripts/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="assets/scripts/hr-jquery.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		var $author;
		contentGetArticle();
		function contentGetArticle(){
			$.get("contentGetArticle",function(data){
				var $postD = data.postD.split(".")[0];
				$("#title").html(data.title);
				$("#type").html(data.type);
				$("#tag").html(data.tag);
				$("#postD").html($postD);
				$("#intro").html("简介："+data.intro);
				$("#content").html(data.content);
				$("#readN").html(data.readN);
				$("#tuijianN").html(data.recommendN);
				$("#tag").attr("href","list?tag="+data.tag);
				$("#author").html(data.author);
				$("#userPic").attr("src",data.userPic);
				$author=data.author;
				getTotal();
				getYCTotal();
				$(".authorInfo a").attr("href","center?author="+$author);
			});
		}
		
		function getTotal(){
			$.get("getArticlesByName?author="+$author,function(data){
				$("#total").html(data);
			});
		}
		
		function getYCTotal(){
			$.get("getYCArticlesByName?author="+$author,function(data){
				$("#ycTotal").html(data);
			});
		}
		
		//阅读top
	  	$.get("readTop",function(data){
	  		var $articles = data.pageInfo.list;
	  		$("#readTop li").remove();
	  		var $readTopBox = $("#readTop");
	  		for(var i=0;i<$articles.length;i++){
	  			var $li = $('<li><a href="content?id='+$articles[i].id+'">'+$articles[i].title+'</a></li>');
	  			$readTopBox.append($li);
	  		}
	  	});
	  	//阅读top
	  	//推荐Top
	  	$.get("tuijianTop",function(data){
	  		var $articles = data.pageInfo.list;
	  		$("#tuijianTop li").remove();
	  		var $tuijianTopBox = $("#tuijianTop");
	  		for(var i=0;i<$articles.length;i++){
	  			var $li = $('<li><a href="content?id='+$articles[i].id+'">'+$articles[i].title+'</a></li>');
	  			$tuijianTopBox.append($li);
	  		}
	  	});
	  	//推荐Top
	  	
	  	//推荐button
	  	$("#tuijian").click(function(){
	  		if($("#center").length != 0){
	  			$.get("tuijianCtrl",function(data){
	  				if(data.res==1){
	  					$("#tuijianN").html(data.recommendN);
	  				}else{
	  					alert(data.resMsg);
	  				}
	  			});
	  		}else{
	  			var $register = confirm("需要登录才可以推荐文章，马上去登录？");
	  			if($register){
	  				window.location.href="login";
	  			}else{
	  				return false;
	  			}
	  		}
	  	});
	  	//推荐button
	});
</script>
</body>
</html>